package com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzsoft.zhjd.common.annotation.ZhjdDataFilter;
import com.qzsoft.zhjd.common.components.BaseServiceComponent;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.dto.LaboratoryFurnaceDayDto;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.dto.LaboratoryFurnaceDto;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.dto.LaboratoryFurnaceResultDto;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.dto.LaboratoryFurnaceStatisticsDto;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.dto.LaboratoryFurnaceValueDto;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.entity.LaboratoryFurnaceEntity;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.mapper.LaboratoryFurnaceMapper;
import com.qzsoft.zhjd.laboratory.modules.laboratoryfurnace.service.LaboratoryFurnaceService;

/**
 * @ClassName LaboratoryFurnaceServiceImpl
 * @Description 燃烧炉业务接口实现
 * @author linhuawei
 * @since 2022-04-18
 */
@Service
public class LaboratoryFurnaceServiceImpl extends ServiceImpl<LaboratoryFurnaceMapper, LaboratoryFurnaceEntity>
        implements LaboratoryFurnaceService {

    @Autowired
    private BaseServiceComponent baseServiceComponent;

    @Override
    @ZhjdDataFilter(tableAlias = "t1")
    public IPage<LaboratoryFurnaceDto> pageDto(Map<String, Object> params) {
        IPage<LaboratoryFurnaceDto> page = baseServiceComponent.getPage(params, LaboratoryFurnaceDto.class);
        return baseMapper.queryDto(page, params);
    }

    @Override
    @ZhjdDataFilter(tableAlias = "t1")
    public LaboratoryFurnaceStatisticsDto dataForStatistics(Map<String, Object> params) {
        // 获取合格占比数据
        LaboratoryFurnaceResultDto result = baseMapper.countByResult(params);

        // 获取每天试验次数数据
        List<LaboratoryFurnaceDayDto> dayList = baseMapper.countByResultForDay(params);

        // 获取具体试验数据
        List<LaboratoryFurnaceValueDto> valueList = baseMapper.listForAsphaltAggregateRatio(params);

        // 返回结果
        LaboratoryFurnaceStatisticsDto dto = new LaboratoryFurnaceStatisticsDto();
        dto.setDayList(dayList);
        dto.setResult(result);
        dto.setValueList(valueList);
        return dto;
    }

}
